<template>
  <!-- 维护作业-授权等级维护页面 -->
  <div class="fillcontain">
    <el-form :model="searchParams" :rules="rules" ref="ruleForm" label-width="100px" class="search_container">
      <el-row>
        <el-col :span="6">
          <el-form-item label="核保等级" prop="uwlevel">
            <el-select v-model="searchParams.uwlevel" clearable placeholder="请选择">
              <el-option
                  v-for="item in uwlevels"
                  :key="item.value"
                  :label="item.option"
                  :value="item.value">
              </el-option>
            </el-select>
            <!-- <el-input v-model="searchParams.customerName" placeholder="险种代码"></el-input> -->
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="核保类别" prop="uwtype">
            <!-- <el-input v-model="searchParams.uwtype" placeholder="主附约"></el-input> -->
            <el-select v-model="searchParams.uwtype" clearable placeholder="请选择">
              <el-option
                  v-for="item in uwtypes"
                  :key="item.value"
                  :label="item.option"
                  :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6" class="text_center">
          <el-button type="primary" icon="el-icon-search" @click="subGetList"></el-button>
          <el-button type="primary" plain icon="el-icon-refresh" @click="resetSearch"></el-button>
        </el-col>
      </el-row>
    </el-form>
    <div class="contain">
      <el-row class="bgfff pb15">
        <el-col :span="24" class="pt5">
          <el-button type="danger" plain @click="fatherAddClick">新增</el-button>
          <el-button type="danger" plain @click="fatherCopyClick">拷贝</el-button>
        </el-col>
      </el-row>
      <!-- 主表显示结果 -->
      <div class="table_container">
        <el-table
            v-loading="loading"
            @row-click="searchDataForSon"
            :data="insCodetableData"
            highlight-current-row
            header-cell-class-name="table-header-class"
            style="width:100%">
          <el-table-column
              min-width="120"
              :formatter="uwlevelFormatter"
              property="uwlevel"
              label="核保等级"
              align='center'
              show-overflow-tooltip>
          </el-table-column>
          <el-table-column
              min-width="120"
              :formatter="uwtypeFormatter"
              property="uwtype"
              label="核保类别"
              align='center'
              show-overflow-tooltip>
          </el-table-column>
          <el-table-column
              property="gramt"
              label="授权额度"
              align='center'
              show-overflow-tooltip>
          </el-table-column>
          <el-table-column
              min-width="120"
              property="agcomrt"
              label="加费频点"
              align='center'
              show-overflow-tooltip>
          </el-table-column>
          <el-table-column
              min-width="120"
              property="flag01"
              label="是否使用二期权限"
              align='center'
              show-overflow-tooltip>
          </el-table-column>
          <el-table-column
              min-width="120"
              property="flag02"
              label="单位"
              align='center'
              show-overflow-tooltip>
          </el-table-column>
          <el-table-column
              min-width="120"
              label="操作"
              fixed="right"
              align='center'>
            <template slot-scope="scope">
              <!-- <el-button type="text" size="small" @click="mianUpdateGo(scope.row)">修改</el-button> -->
              <span class="operationIcon" @click="mianUpdateGo(scope.row)">
                            <el-tooltip class="item" effect="light" content="修改" placement="top">
                                <i class="el-icon-edit"></i>
                            </el-tooltip>
                        </span>
              <!-- <el-button type="text" size="small" @click="fatherDelete(scope.row)">删除</el-button> -->
              <span class="operationIcon ml5" @click="fatherDelete(scope.row)">
                             <el-tooltip class="item" effect="light" content="删除" placement="top">
                                <i class="el-icon-delete"></i>
                            </el-tooltip>
                        </span>

            </template>
          </el-table-column>
        </el-table>
        <el-row>
          <el-col :span="24">
            <div class="pagination">
              <el-pagination
                  background
                  v-if='fatherPaginations.total > 0'
                  :page-sizes="fatherPaginations.pageSizes"
                  :page-size="fatherPaginations.pageSize"
                  :layout="fatherPaginations.layout"
                  :total="fatherPaginations.total"
                  :current-page='fatherPaginations.pageIndex'
                  @current-change='handleCurrentChange'
                  @size-change='handleSizeChange'>
              </el-pagination>
            </div>
          </el-col>
        </el-row>
      </div>

      <!-- 附档显示结果 -->
      <div class="table_container mt20" v-if="showSonTable">
        <el-row class="bgfff pb15">
          <el-col :span="24" class="pt5">
            <el-button type="danger" @click="sonAddClick" plain>新增</el-button>
            <el-button type="danger" @click="sonCopyClick" plain>拷贝</el-button>
          </el-col>
        </el-row>
        <el-table
            v-loading="loading"
            :data="attachedtableData"
            @row-click="sonRowClick"
            highlight-current-row
            header-cell-class-name="table-header-class"
            style="width:100%">
          <el-table-column
              min-width='120'
              property="uwlevel"
              :formatter="uwlevelFormatter"
              label="核保等级"
              align='center'
              show-overflow-tooltip>
          </el-table-column>
          <el-table-column
              min-width='120'
              property="uwtype"
              :formatter="uwtypeFormatter"
              label="核保类别"
              align='center'
              show-overflow-tooltip>
          </el-table-column>
          <el-table-column
              min-width='120'
              property="eutblord"
              label="子级别"
              align='center'
              show-overflow-tooltip>
          </el-table-column>
          <el-table-column
              min-width='120'
              property="gramt01"
              label="起始保额"
              align='center'
              show-overflow-tooltip>
          </el-table-column>
          <el-table-column
              min-width='120'
              property="gramt02"
              label="终止保额"
              align='center'
              show-overflow-tooltip>
          </el-table-column>
          <el-table-column
              min-width='120'
              property="agcomrt01"
              label="起始加额费"
              align='center'
              show-overflow-tooltip>
          </el-table-column>
          <el-table-column
              min-width='120'
              property="agcomrt02"
              label="终止加费额"
              align='center'
              show-overflow-tooltip>
          </el-table-column>
          <el-table-column
              label="操作"
              fixed="right"
              align='center'>
            <template slot-scope="scope">
              <!-- <el-button type="text" size="small" @click="attachedUpdateGo(scope.row)">修改</el-button> -->
              <span class="operationIcon" @click="attachedUpdateGo(scope.row)">
                            <el-tooltip class="item" effect="light" content="修改" placement="top">
                                <i class="el-icon-edit"></i>
                            </el-tooltip>
                        </span>
              <!--<el-button type="text" size="small" @click="sonDelete(scope.row)">删除</el-button> -->
              <span class="operationIcon ml5" @click="sonDelete(scope.row)">
                             <el-tooltip class="item" effect="light" content="删除" placement="top">
                                <i class="el-icon-delete"></i>
                            </el-tooltip>
                        </span>

            </template>
          </el-table-column>
        </el-table>
        <el-row>
          <el-col :span="24">
            <div class="pagination">
              <el-pagination
                  background
                  v-if='sonPaginations.total > 0'
                  :page-sizes="sonPaginations.pageSizes"
                  :page-size="sonPaginations.pageSize"
                  :layout="sonPaginations.layout"
                  :total="sonPaginations.total"
                  :current-page='sonPaginations.pageIndex'
                  @current-change='sonHandleCurrentChange'
                  @size-change='sonHandleSizeChange'>
              </el-pagination>
            </div>
          </el-col>
        </el-row>
      </div>
    </div>

    <!-- 弹框 主档修改信息-->
    <el-dialog
        title="授权等级维护主表修改"
        :visible.sync="mainDialog"
        width="60%"
        center>
      <el-form ref="fatherForm" :rules="fatherRules" :model="fatherForm" label-width="120px">
        <el-row>
          <el-col :span="12" class="common-box">
            <el-form-item label="核保等级" prop="uwlevel">
              <el-select v-model="fatherForm.uwlevel" placeholder="">
                <el-option
                    v-for="item in uwlevels"
                    :key="item.value"
                    :label="item.option"
                    :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12" class="common-box">
            <el-form-item label="核保类别" prop="uwtype">
              <el-select v-model="fatherForm.uwtype" placeholder="">
                <el-option
                    v-for="item in uwtypes"
                    :key="item.value"
                    :label="item.option"
                    :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12" class="common-box">
            <el-form-item label="授权额度" prop="gramt">
              <el-input-number v-model="fatherForm.gramt" :precision="2" :max="9999999999999.99"
                               class="number-input-text" :controls="false"></el-input-number>
            </el-form-item>
            <!-- <el-col :span="6" class="common-lab">
                 <label class="labelName">授权额度</label>
            </el-col>
             <el-col :span="16">
                 <el-input placeholder=""></el-input>
             </el-col> -->
          </el-col>
          <el-col :span="12" class="common-box">
            <el-form-item label="加费频点" prop="agcomrt">
              <el-input-number v-model="fatherForm.agcomrt" :precision="2" :max="999.99" class="number-input-text"
                               :controls="false"></el-input-number>
            </el-form-item>
            <!-- <el-col :span="6" class="common-lab">
                 <label class="labelName">加费频点</label>
            </el-col>
             <el-col :span="16">
                 <el-input placeholder=""></el-input>
             </el-col> -->
          </el-col>
          <el-col :span="12" class="common-box">
            <el-form-item label="是否使用二级权限" prop="flag01">
              <el-select v-model="fatherForm.flag01" placeholder="">
                <el-option
                    v-for="item in flagOptions"
                    :key="item.value"
                    :label="item.option"
                    :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <!-- <el-col :span="6" class="common-lab">
                <label class="labelName">是否使用<br/>二级权限</label>
            </el-col>
             <el-col :span="16">
                <el-input placeholder=""></el-input>
             </el-col> -->
          </el-col>
          <el-col :span="12" class="common-box">
            <el-form-item label="单位" prop="flag02">
              <el-select v-model="fatherForm.flag02" placeholder="">
                <el-option
                    v-for="item in flagOptions"
                    :key="item.value"
                    :label="item.option"
                    :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <!-- <el-col :span="6" class="common-lab">
                <label class="labelName">单位</label>
            </el-col>
             <el-col :span="16">
                <el-input placeholder=""></el-input>
             </el-col> -->
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
                <el-button @click="fatherInfoSave" class="Defaultbutton">保 存</el-button>
                <el-button @click="mainDialog = false">返 回</el-button>
            </span>
    </el-dialog>

    <!-- 弹框 附档修改信息-->
    <el-dialog
        title="授权等级维护附表修改"
        :visible.sync="attachedDialog"
        width="60%"
        center>
      <el-form ref="sonForm" :rules="sonRules" :model="sonForm" label-width="120px">
        <el-row>
          <el-col :span="12" class="common-box">
            <el-form-item label="核保等级" prop="uwlevel">
              <el-select v-model="sonForm.uwlevel" :disabled="true" placeholder="">
                <el-option
                    v-for="item in uwlevels"
                    :key="item.value"
                    :label="item.option"
                    :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <!-- <el-col :span="6" class="common-lab">
                 <label class="labelName">核保等级</label>
            </el-col>
             <el-col :span="16">
                <el-select v-model="form.uwlevel" placeholder="" >
                    <el-option
                        v-for="item in uwlevels"
                        :key="item.value"
                        :label="item.option"
                        :value="item.value">
                    </el-option>
                </el-select>
             </el-col> -->
          </el-col>
          <el-col :span="12" class="common-box">
            <el-form-item label="核保类别" prop="uwtype">
              <el-select v-model="sonForm.uwtype" :disabled="true" placeholder="">
                <el-option
                    v-for="item in uwtypes"
                    :key="item.value"
                    :label="item.option"
                    :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <!-- <el-col :span="6" class="common-lab">
                 <label class="labelName">核保类别</label>
            </el-col>
             <el-col :span="16">
                <el-select v-model="form.uwtype" placeholder="" >
                    <el-option
                        v-for="item in uwtypes"
                        :key="item.value"
                        :label="item.option"
                        :value="item.value">
                    </el-option>
                </el-select>
             </el-col> -->
          </el-col>
          <el-col :span="12" class="common-box">
            <el-form-item label="子类别" prop="eutblord">
              <el-input clearable v-model="sonForm.eutblord"
                        :disabled="sonForm.method=='modify' ? true : false"></el-input>
            </el-form-item>
            <!-- <el-col :span="6" class="common-lab">
                 <label class="labelName">子类别</label>
            </el-col>
             <el-col :span="16">
                <el-input placeholder=""></el-input>
             </el-col> -->
          </el-col>
          <el-col :span="12" class="common-box">
            <el-form-item label="起始保额" prop="gramt01">
              <el-input-number v-model="sonForm.gramt01" :precision="2" :max="9999999999999.99"
                               class="number-input-text" :controls="false"></el-input-number>
            </el-form-item>
            <!-- <el-col :span="6" class="common-lab">
                 <label class="labelName">起始保额</label>
            </el-col>
             <el-col :span="16">
                 <el-input placeholder=""></el-input>
             </el-col> -->
          </el-col>
          <el-col :span="12" class="common-box">
            <el-form-item label="终止保额" prop="gramt02">
              <el-input-number v-model="sonForm.gramt02" :precision="2" :max="9999999999999" class="number-input-text"
                               :controls="false"></el-input-number>
            </el-form-item>
            <!-- <el-col :span="6" class="common-lab">
                 <label class="labelName">终止保额</label>
            </el-col>
             <el-col :span="16">
                <el-input placeholder=""></el-input>
             </el-col> -->
          </el-col>
          <el-col :span="12" class="common-box">
            <el-form-item label="起始加费额" prop="agcomrt01">
              <el-input-number v-model="sonForm.agcomrt01" :precision="2" :max="999.99" class="number-input-text"
                               :controls="false"></el-input-number>
            </el-form-item>
            <!-- <el-col :span="6" class="common-lab">
                 <label class="labelName">起始加费额</label>
            </el-col>
             <el-col :span="16">
                 <el-input placeholder=""></el-input>
             </el-col> -->
          </el-col>
          <el-col :span="12" class="common-box">
            <el-form-item label="终止加费额" prop="agcomrt02">
              <el-input-number v-model="sonForm.agcomrt02" :precision="2" :max="999.99" class="number-input-text"
                               :controls="false"></el-input-number>
            </el-form-item>
            <!-- <el-col :span="6" class="common-lab">
                 <label class="labelName">终止加费额</label>
            </el-col>
             <el-col :span="16">
                 <el-input placeholder=""></el-input>
             </el-col> -->
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
                <el-button @click="sonInfoSave" class="Defaultbutton">保 存</el-button>
                <el-button @click="attachedDialog = false">返 回</el-button>
            </span>
    </el-dialog>

  </div>
</template>

<script>
  import {mapState, mapGetters} from 'vuex'
  import constant from '@/utils/constant';
  import * as api from '@/api/setting/maintain/authorizeLevelMaintenance.js'

  export default {
    data() {
      return {
        mainDialog: false,//默认隐藏 授权等级维护主表修改弹框
        attachedDialog: false,//默认隐藏 授权等级维护附表修改弹框

        // 查询条件
        rules: {
          customerNo: [],
          customerName: [],
          idNo: [],
        },
        fatherRules: {
          uwlevel: [
            {required: true, message: '请输入核保等级', trigger: 'blur'}
          ],
          uwtype: [
            {required: true, message: '请输入核保类别', trigger: 'blur'}
          ],
          gramt: [
            {required: true, message: '请输入授权额度', trigger: 'blur'}
          ],
          agcomrt: [
            {required: true, message: '请输入加费频点', trigger: 'blur'}
          ],
          flag01: [],
          flag02: [],
        },
        sonRules: {
          uwlevel: [
            {required: true, message: '请输入核保等级', trigger: 'blur'}
          ],
          uwtype: [
            {required: true, message: '请输入核保类别', trigger: 'blur'}
          ],
          eutblord: [
            {required: true, message: '请输入子级别', trigger: 'blur'}
          ],
          gramt01: [
            {required: true, message: '请输入起始保额', trigger: 'blur'}
          ],
          gramt02: [
            {required: true, message: '请输入终止保额', trigger: 'blur'}
          ],
          agcomrt01: [
            {required: true, message: '请输入起始加费额', trigger: 'blur'}
          ],
          agcomrt02: [
            {required: true, message: '请输入终止加费额', trigger: 'blur'}
          ],
        },
        searchParams: {
          uwtype: '',
          uwlevel: '',
        },
        insCodetableData: [//主档数据
        ],
        attachedtableData: [//附档数据
        ],
        loading: false,
        showSonTable: false,

        form: [//主档弹框表单
          {
            customerName: '',
          }
        ],
        fatherForm: {
          uwlevel: '',
          uwtype: '',
          gramt: '',
          agcomrt: '',
          flag01: '',
          flag02: '',
          flag03: '',
        },
        sonForm: {
          uwlevel: '',
          uwtype: '',
          eutblord: '',
          gramt01: '',
          gramt02: '',
          agcomrt01: '',
          agcomrt02: '',
          flag01: '',
          flag02: '',
          flag03: '',
        },
        uwtypes: [],
        uwlevels: [],
        selectFatherRow: {},
        selectSonRow: {},
        flagOptions: [
          {
            option: 'Y',
            value: 'Y',
          },
          {
            option: 'N',
            value: 'N',
          }
        ],
        //需要给分页组件传的信息
        fatherPaginations: {
          total: 0,        // 总数
          pageIndex: 1,  // 当前位于哪页
          pageSize: 10,   // 1页显示多少条
          pageSizes: [5, 10, 15, 20],  //每页显示多少条
          layout: "total, sizes, prev, pager, next, jumper"   // 翻页属性
        },
        sonPaginations: {
          total: 0,        // 总数
          pageIndex: 1,  // 当前位于哪页
          pageSize: 10,   // 1页显示多少条
          pageSizes: [5, 10, 15, 20],  //每页显示多少条
          layout: "total, sizes, prev, pager, next, jumper"   // 翻页属性
        },
        pickerOptions1: {
          disabledDate(time) {
            return time.getTime() > Date.now();
          }
        }
      }
    },
    created() {
//          this.getList();
      this.init();
    },
    mounted() {
      // this.getList();
    },
    methods: {
      init() {
        api.getSelectByUwlevel().then(res => {
          this.$store.dispatch('loading/CHANGE_LOADING', false)
          if (res.resultCode == constant.SUCCESS && res.data) {
            this.uwlevels = [...res.data];
          }

        }).catch(err => {
          this.$store.dispatch('loading/CHANGE_LOADING', false);
        })

        api.getSelectByUwtype().then(res => {
          this.$store.dispatch('loading/CHANGE_LOADING', false)
          if (res.resultCode == constant.SUCCESS && res.data) {
            this.uwtypes = [...res.data];
          }

        }).catch(err => {
          this.$store.dispatch('loading/CHANGE_LOADING', false);
        })
      },
      mianUpdateGo(row) {
        this.mainDialog = true;
        if (this.$refs['fatherForm']) {
          this.$refs['fatherForm'].resetFields();
        }
        Object.assign(this.fatherForm, row);
        this.fatherForm.method = 'modify';
      },
      attachedUpdateGo(row) {
        this.attachedDialog = true;
        if (this.$refs['sonForm']) {
          this.$refs['sonForm'].resetFields();
        }
        Object.assign(this.sonForm, row);
        this.sonForm.method = "modify";
      },


      // 查询列表
      getList() {
        this.showSonTable = false;
        this.fatherPaginations.total = 0;
        this.insCodetableData = [];
        let para = {
          "uwlevel": this.searchParams.uwlevel,
          "uwtype": this.searchParams.uwtype,
          "pageSize": this.fatherPaginations.pageSize,
          "pageNumber": this.fatherPaginations.pageIndex,
        }
        this.$store.dispatch('loading/CHANGE_LOADING', true)
        api.queryListForFather(para).then(res => {
          this.$store.dispatch('loading/CHANGE_LOADING', false)
          if (res.resultCode == constant.SUCCESS && res.data && res.data.list.length) {
            this.fatherPaginations.total = res.data.total;
            this.insCodetableData = res.data.list;
          }

        }).catch(err => {
          this.$store.dispatch('loading/CHANGE_LOADING', false);
        })
      },
      getSonList() {
        let para = {
          "uwlevel": this.selectFatherRow.uwlevel,
          "uwtype": this.selectFatherRow.uwtype,
          "pageSize": this.sonPaginations.pageSize,
          "pageNumber": this.sonPaginations.pageIndex,
        }
        this.sonPaginations.total = 0;
        this.attachedtableData = [];
        api.queryListForSon(para).then(res => {
          this.$store.dispatch('loading/CHANGE_LOADING', false)
          if (res.resultCode == constant.SUCCESS) {
            if (res.data && res.data.list.length) {
              this.sonPaginations.total = res.data.total;
              this.attachedtableData = res.data.list;
            } else {
              this.$message({
                message: '对不起，没有查询到数据',
                type: 'warn'
              })
            }
          }
        }).catch(err => {
          this.$store.dispatch('loading/CHANGE_LOADING', false);
        })
      },
      searchDataForSon(row) {
        this.showSonTable = true;
        this.selectFatherRow = row;
        this.subSonGetList();
      },
      // 每页多少条切换
      handleSizeChange(pageSize) {
        this.fatherPaginations.pageSize = pageSize;
        this.getList();
      },
      // 上下分页
      handleCurrentChange(page) {
        this.fatherPaginations.pageIndex = page;
        this.getList();
      },
      // 每页多少条切换
      sonHandleSizeChange(pageSize) {
        this.sonPaginations.pageSize = pageSize;
        this.getList();
      },
      // 上下分页
      sonHandleCurrentChange(page) {
        this.sonPaginations.pageIndex = page;
        this.getList();
      },
      // 根据条件查询列表
      subGetList() {
        this.fatherPaginations.pageIndex = 1;
        this.getList();
      },
      subSonGetList() {
        this.sonPaginations.pageIndex = 1;
        this.getSonList();
      },
      // 清除查询条件
      resetSearch() {
        this.searchParams.uwtype = '';
        this.searchParams.uwlevel = '';
      },
      uwlevelFormatter(row) {
        for (let i = 0, len = this.uwlevels.length; i < len; i++) {
          if (this.uwlevels[i].value == row.uwlevel) {
            return this.uwlevels[i].option;
          }
        }
      },
      uwtypeFormatter(row) {
        for (let i = 0, len = this.uwtypes.length; i < len; i++) {
          if (this.uwtypes[i].value == row.uwtype) {
            return this.uwtypes[i].option;
          }
        }
      },
      fatherAddClick() {
        this.mainDialog = true;
        if (this.$refs['fatherForm']) {
          this.$refs['fatherForm'].resetFields();
        }
        this.fatherForm.method = "add";
      },
      fatherCopyClick() {
        if (this.$refs['fatherForm']) {
          this.$refs['fatherForm'].resetFields();
        }

        let uwlevel = this.selectFatherRow.uwlevel;
        let uwtype = this.selectFatherRow.uwtype;
        let gramt = this.selectFatherRow.gramt;
        let agcomrt = this.selectFatherRow.agcomrt;
        let flag01 = this.selectFatherRow.flag01;

        if (uwlevel == '' || uwlevel == null || uwtype == '' || uwtype == null) {
          this.$message.error("请选择一条数据");
          return;
        } else {
          this.fatherForm.gramt = gramt;
          this.fatherForm.agcomrt = agcomrt;
          this.fatherForm.flag01 = flag01;
        }
        this.fatherForm.method = "add";
        this.mainDialog = true;
      },
      fatherInfoSave() {
        this.$refs['fatherForm'].validate((valid) => {
          if (valid) {
            this.$store.dispatch('loading/CHANGE_LOADING', true)
            api.editData(this.fatherForm).then(res => {
              this.$store.dispatch('loading/CHANGE_LOADING', false)
              if (res.resultCode == constant.SUCCESS) {
                this.$message.success(res.resultMsg);
                this.mainDialog = false;
                this.searchParams.uwlevel = this.fatherForm.uwlevel;
                this.searchParams.uwtype = this.fatherForm.uwtype;
                this.subGetList();
              } else {
                // this.$message.error(res.resultMsg);
              }
            }).catch(err => {
              this.$store.dispatch('loading/CHANGE_LOADING', false);
            })
          }
        });
      },
      fatherDelete(row) {
        this.$confirm('确定是否删除？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$confirm('其下有子目录，是否删除？', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            let para = {
              uwlevel: row.uwlevel,
              uwtype: row.uwtype,
            }
            this.$store.dispatch('loading/CHANGE_LOADING', true)
            api.deleteData(para).then(res => {
              this.$store.dispatch('loading/CHANGE_LOADING', false)
              if (res.resultCode == constant.SUCCESS) {
                this.$message.success(res.resultMsg);
                this.subGetList();
              } else {
                this.$message.error(res.resultMsg);
              }
            }).catch(err => {
              this.$store.dispatch('loading/CHANGE_LOADING', false);
            })
            api.deleteSubData(para).then(res => {
              console.log("删除子级" + res);
            }).catch(err => {
              console.log("删除子级失败" + err);
            })

          }).catch(() => {
            this.$message({
              type: 'info',
              message: '已取消修改'
            });
          });

        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消修改'
          });
        });
      },
      sonRowClick(row) {
        this.selectSonRow = row;
      },
      sonAddClick() {
        debugger
        this.attachedDialog = true;
        if (this.$refs['sonForm']) {
          this.$refs['sonForm'].resetFields();
        }
        this.sonForm.uwlevel = this.selectFatherRow.uwlevel;
        this.sonForm.uwtype = this.selectFatherRow.uwtype;
        this.sonForm.method = "add";
      },
      sonCopyClick() {
        if (this.$refs['sonForm']) {
          this.$refs['sonForm'].resetFields();
        }

        let uwlevel = this.selectSonRow.uwlevel;
        let uwtype = this.selectSonRow.uwtype;

        if (uwlevel == '' || uwlevel == null || uwtype == '' || uwtype == null) {
          this.$message.error("请选择一条数据");
          return;
        } else {
          this.sonForm.uwlevel = this.selectSonRow.uwlevel;
          this.sonForm.uwtype = this.selectSonRow.uwtype;
          this.sonForm.gramt01 = this.selectSonRow.gramt01;
          this.sonForm.gramt02 = this.selectSonRow.gramt02;
          this.sonForm.agcomrt01 = this.selectSonRow.agcomrt01;
          this.sonForm.agcomrt02 = this.selectSonRow.agcomrt02;
        }
        this.sonForm.method = "add";
        this.attachedDialog = true;
      },
      sonInfoSave() {
        this.$refs['sonForm'].validate((valid) => {
          if (valid) {
            api.editSubData(this.sonForm).then(res => {
              this.$store.dispatch('loading/CHANGE_LOADING', false)
              if (res.resultCode == constant.SUCCESS) {
                this.$message.success(res.resultMsg);
                this.attachedDialog = false;
                this.subSonGetList();
              } else {
                this.$message.error(res.resultMsg);
              }
            }).catch(err => {
              this.$store.dispatch('loading/CHANGE_LOADING', false);
            })
          }
        });
      },
      sonDelete(row) {
        this.$confirm('确定是否删除？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          let para = {
            uwlevel: row.uwlevel,
            uwtype: row.uwtype,
            eutblord: row.eutblord,
          }
          api.deleteSubData(para).then(res => {
            this.$store.dispatch('loading/CHANGE_LOADING', false)
            if (res.resultCode == constant.SUCCESS) {
              this.$message.success(res.resultMsg);
              this.attachedDialog = false;
              this.subSonGetList();
            } else {
              this.$message.error(res.resultMsg);
            }
          }).catch(err => {
            this.$store.dispatch('loading/CHANGE_LOADING', false);
          })

        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消修改'
          });
        });
      },
    },
    computed: {
      ...mapGetters(['tags']),
      reload() {
        return this.$store.state.loading.reload;
      }
    },
    activated() {
      if (this.reload) {
        this.$store.dispatch('loading/CHNAGE_RELOAD', false)
        Object.assign(this.$data, this.$options.data());
      }
    }
  }
</script>

<style lang="less" scoped>
  // 通过/deep/可以修改组件内部样式
  .number-input-text /deep/ .el-input__inner {
    text-align: left;
  }

  .fillcontain {
    padding-bottom: 0;
  }

  .contain {
    background: #fff;
    padding: 10px;
    margin-bottom: 20px;
  }

  .pagination {
    padding: 10px 20px;
    text-align: right;
  }

  .operationIcon {
    // padding: 12px;
    border: 1px solid #e5e5e5;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: inline-block;
    cursor: pointer;
    box-shadow: 0 0 3px #f9f9f9;
  }

  .search_container {
    padding: 20px 20px 0 20px;
    //    border-top: 1px solid #e1e1e1;
  }

  .common-box {
    padding-bottom: 15px;
  }

  .common-lab {
    line-height: normal !important;
    text-align: right;

    .labelName {
      text-align: right;
    }
  }
</style>



